using System;
using System.Collections.Generic;
using System.Text;

namespace Anarchy
{

    enum ImageDetail
    {
        ID,
        Path,
        Filename,
        Checksum,
        Filesize,
        Tags
    }

    enum Relationship
    {
        EqualTo,
        Contains,
        GreaterThan,
        LessThan,
        GreaterThanOrEqualTo,
        LessThanOrEqualTo,
        Not
    }

    class ImageCriteria : ImageValue
    {
        public Relationship Relationship;
    }

    class ImageValue
    {
        public ImageDetail Detail;
        public string Value;
    }

    class ImageList
    {
        Dictionary<ImageDetail, string>[] Dict;
        public string this[int ID, ImageDetail Detail]
        {
            get
            {

                // Do we have ID?
                if ((ID < Dict.GetLowerBound(0)) || (ID > Dict.GetUpperBound(0)))
                    throw new Exception("Requested detail for an ID outside the bounds of the ImageList.");

                // Does it have the specified detail?
                if (Dict[ID].ContainsKey(Detail))
                    // Return appropriate details
                    return Dict[ID][Detail];
                else
                    // Return an empty string to keep 'em happy :)
                    return string.Empty;

            }
            set
            {

                // Do we have ID?
                if ((ID < Dict.GetLowerBound(0)) || (ID > Dict.GetUpperBound(0)))
                    throw new Exception("Tried setting a detail for an ID outside the bounds of the ImageList.");

                // Does it have the specified detail?
                if (Dict[ID].ContainsKey(Detail))
                    // Update
                    Dict[ID][Detail] = value;
                else
                    // Add
                    Dict[ID].Add(Detail, value);

            }
        }
        public int Length
        {
            get
            {
                return Dict.Length;
            }
        }
        public ImageList(int Len)
        {

            // Declare the dict & fill
            Dict = new Dictionary<ImageDetail,string>[Len];
            for (int i = 0; i < Len; i++)
                Dict[i] = new Dictionary<ImageDetail,string>();
        }
        public void Add(int ID, ImageDetail Detail, string Value)
        {

            // Do we have ID?
            if ((ID < Dict.GetLowerBound(0)) || (ID > Dict.GetUpperBound(0)))
                throw new Exception("Tried adding a detail for ID outside the bounds of the ImageList.");

            // Exist already?
            if (Dict[ID].ContainsKey(Detail))
                Dict[ID][Detail] = Value;
            else
                Dict[ID].Add(Detail, Value);

        }
    }

}
